package com.design.pattern.stratogy;


import com.design.pattern.stratogy.behavior.FlyBehavior;
import com.design.pattern.stratogy.behavior.QuackBehavior;

public abstract class Duck {

    protected FlyBehavior flyBehavior;
    protected QuackBehavior quackBehavior;

    public Duck(){

    }

    protected void swim(){
        System.out.println("所有的鸭子都会游泳");
    }

    protected  abstract void display();

    protected void  performFly(){
        flyBehavior.fly();
    }

    protected void performQuack(){
        quackBehavior.quack();
    }

    public void setFlyBehavior(FlyBehavior flyBehavior) {
        this.flyBehavior = flyBehavior;
    }

    public void setQuackBehavior(QuackBehavior quackBehavior) {
        this.quackBehavior = quackBehavior;
    }
}